usrName = Sys.getenv("USER")

if (usrName =='kacper'){
  path<- '/home/kacper/dev/timeser/time-series-pred/src'
}else{
  if (usrName =='mateusz')
    path<- '/home/mateusz/workspace/TS1/time-series-pred/src'
}
if(usrName =='kc262414'){
  path <-"/home/students/mismap/k/kc262414/studia/szeregi/time-series-pred/src"
}

setwd(path)
ppp<-path
if(!exists('raw_predict', mode="function")) source("readData.R")
path<-ppp

forecast <- function(x12,symbol){
  if (symbol == 'USDEUR'){
    
  }else if (symbol =='GOOG'){
    forecast <-ownPredict(x12, ARSmoothedDataPredict,250, logReturnTransform, logReturnDeTransform)
  }else if (symbol=='ZF'){
    
  }else if (symbol =='CL'){
    
  }else{
    print('unknown symbol')
  }
  return(forecast)
}

ownPredict <-function(timeSeries, 
                   forcastingFunction,
                   maxHistory=10000,
                   transformData=function(x) return(x),
                   detransformData=NA){
  
  predictedTimeSeries <- raw_predict(timeSeries, 
                                     index(timeSeries),
                                     forcastingFunction,
                                     maxHistory,
                                     transformData,
                                     detransformData) 
  
  lastYear <- extractLastYear(timeSeries)
  tsLength <-length(timeSeries)
  firstUnknown<-1
  
  while( as.POSIXlt(index(timeSeries[firstUnknown]))$year < lastYear ){
    firstUnknown<-firstUnknown+1
  }
  
  realTimeSeries <- timeSeries[firstUnknown:tsLength]
  aafe <- mean(abs(realTimeSeries-predictedTimeSeries))
  list(x2=realTimeSeries,y2=predictedTimeSeries,aafe=aafe)
}

# ret <-ownPredict(zf,autoSim,10000,function(x) return(x), simDeTrans)
# ret <-ownPredict(cl,autoSim,10000,function(x) return(x), simDeTrans)
# ret <-ownPredict(google,autoSim,10000,function(x) return(x), simDeTrans)
# 
# plot(ret$x2)
# lines(ret$y2)
# ret$aafe


